package net.stuffrepos.bricknetcenter.util.gui.inputcomponent;

import javax.swing.text.JTextComponent;
import net.stuffrepos.bricknetcenter.util.gui.inputcomponent.InputComponentValueParser.ValueResult;

/**
 *
 * @author Eduardo H. Bogoni <eduardobogoni@gmail.com>
 */
public class TextComponentStringParser implements InputComponentValueParser<JTextComponent, String> {

    @Override
    public ValueResult<String> fromComponent(JTextComponent component) {
        return new ValueResult<String>(component.getText(), true);
    }

    @Override
    public void toComponent(JTextComponent component, String value) {
        component.setText(value);
    }

    @Override
    public void setEditable(JTextComponent component, boolean editable) {
        component.setEditable(editable);
    }
}
